package com.littlerpc.protocol.net.common;

import lombok.Getter;
import lombok.Setter;

import java.lang.reflect.Method;
import java.util.UUID;

/**
 *
 * @author ChengPeng
 * @date 2017/6/13
 */
@Setter
@Getter
public class RpcRequest {

    private String requestId;
    private long createMillisTime;
    private String className;
    private String methodName;
    private Class<?>[] parameterTypes;
    private Object[] parameters;

    public static RpcRequest buildRequest(Class<?> interfaceClass, Method method, Object[] args) {
        RpcRequest request = new RpcRequest();
        request.setRequestId(UUID.randomUUID().toString());
        request.setClassName(interfaceClass.getName());
        request.setMethodName(method.getName());
        request.setParameterTypes(method.getParameterTypes());
        request.setParameters(args);
        request.setCreateMillisTime(System.currentTimeMillis());

        return request;

    }

}
